{% extends "admin/pub/base.html" %}

{% block title %}
<title>分类修改</title>
{% endblock %}


{% block js %}
<script src="/static/admin/js/jquery-1.8.3.min.js"></script>
{% endblock %}

{% block con-header %}
{% endblock %}


{% block content-body %}

<div class="widget am-cf">
  <div class="widget-head am-cf">
    <div class="widget-title  am-cf"> 分类修改

<div class="widget-body am-fr">
  <form class="am-form tpl-form-border-form tpl-form-border-br am-u-sm-6 am-u-sm-offset-3" method="post" action="{% url 'type_save' %}">
    <input type="hidden" name="id" value="{{ db.id }}">
    {% csrf_token %}
    <div class="am-form-group">
      <div class="am-form-group">
        <label for="user-name" class="am-u-sm-3 am-form-label">所属分类</label>

        <select name="pid" data-am-selected="{btnSize: 'am'}" style="display: none;">
          {% for i in oball %}
            {% if i.id == db.pid %}
            <option value="{{ i.id }}" selected>{{ i.name }}</option>
            {% else %}
            <option value="{{ i.id }}" disabled>{{ i.name }}</option>
            {% endif %}
          {% endfor %}
          {% if db.pid == 0 %}
            <option value="{{ db.id }}" selected>顶级分类</option>
          {% endif %}

      </select>

      </div>
        <label for="user-name" class="am-u-sm-3 am-form-label">
          <font style="vertical-align: inherit;">
            <font style="vertical-align: inherit;">商品类别(修改)</font></font>
        </label>
        <div class="am-u-sm-6">
          <input type="text" class="tpl-form-input" name="name" value="{{ db.name }}"><br>
        </div>
        <div class="am-form-group">
            <div class="am-u-sm-9 am-u-sm-push-5">
            <button class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
            </div>
        </div>
      </div>
  </form>
</div>

    </div>
  </div>
</div>
{% endblock %}

{% block img_js %}
    <script>
        $(document).ready(function(){
            $('#picture').change(function(){
                var pic1 = this.files[0];
                preview_picture(pic1);
            });
        });
        function preview_picture(pic){
            var r = new FileReader();
            r.readAsDataURL(pic);
            r.onload = function(e){
                $('#img1').attr('src',this.result).show();
            };
        }
    </script>
{% endblock %}